Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(neon_http_client): Add AuthenticationInterceptor #2454

Merged

Conversation

provokateurin
Copy link
Member

Closes #365

Quite simple to implement with our interceptors 😄

Every Account gets it's own NeonHttpClient and therefore it's own AuthenticationInterceptor, so no separation is required.

I removed the catch handlers because the interceptor needs to be able to throw an exception for requests that need to be blocked.

@provokateurin provokateurin force-pushed the feat/neon_http_client/authentication-interceptor branch 2 times, most recently from 4e41991 to bd83703 Compare August 31, 2024 11:19
Copy link

codecov bot commented Aug 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.94%. Comparing base (ac73ec9) to head (114487b).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2454      +/-   ##
==========================================
+ Coverage   29.92%   29.94%   +0.02%     
==========================================
  Files         332      333       +1     
  Lines      124414   124456      +42     
==========================================
+ Hits        37231    37273      +42     
  Misses      87183    87183              
Flag Coverage Δ *Carryforward flag
account_repository 99.64% <ø> (ø)
cookie_store 99.48% <ø> (ø) Carriedforward from ac73ec9
dashboard_app 96.05% <ø> (ø)
dynamite 31.08% <ø> (ø) Carriedforward from ac73ec9
dynamite_end_to_end_test 61.69% <ø> (ø) Carriedforward from ac73ec9
dynamite_runtime 85.40% <ø> (ø) Carriedforward from ac73ec9
neon_dashboard 96.05% <ø> (ø) Carriedforward from ac73ec9
neon_framework 43.65% <ø> (ø)
neon_http_client 94.76% <100.00%> (+1.47%) ⬆️
neon_notifications 100.00% <ø> (ø) Carriedforward from ac73ec9
neon_talk 99.45% <ø> (ø) Carriedforward from ac73ec9
nextcloud 25.90% <ø> (ø)
notifications_app 100.00% <ø> (ø)
sort_box 90.90% <ø> (ø) Carriedforward from ac73ec9
talk_app 99.09% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...rceptors/authorization_throttling_interceptor.dart 100.00% <100.00%> (ø)
...ges/neon_http_client/lib/src/neon_http_client.dart 96.49% <100.00%> (+0.49%) ⬆️

@provokateurin
Copy link
Member Author

I'm not so happy with the name of the interceptor, let me know if there is something more fitting.

@provokateurin provokateurin force-pushed the feat/neon_http_client/authentication-interceptor branch from bd83703 to 685a517 Compare September 5, 2024 09:29
Copy link
Member

@Leptopoda Leptopoda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test that this also work together with the nextcloud package?
I think 401 responses are thrown so the response interceptor wouldn't ever be used.

@provokateurin
Copy link
Member Author

Did you test that this also work together with the nextcloud package?
I think 401 responses are thrown so the response interceptor wouldn't ever be used.

You're thinking on the wrong layer. The response interceptor comes way before the response is parsed in the nextcloud package and an exception might be thrown.

@provokateurin provokateurin force-pushed the feat/neon_http_client/authentication-interceptor branch from 685a517 to 1e6a8ae Compare September 7, 2024 11:41
@provokateurin provokateurin force-pushed the feat/neon_http_client/authentication-interceptor branch from 1e6a8ae to a3571b2 Compare September 7, 2024 11:45
@provokateurin
Copy link
Member Author

Maybe UnauthorizedInterceptor is a better name?

@provokateurin provokateurin force-pushed the feat/neon_http_client/authentication-interceptor branch from a3571b2 to 4bf824d Compare September 7, 2024 15:37
@Leptopoda
Copy link
Member

You're thinking on the wrong layer. The response interceptor comes way before the response is parsed in the nextcloud package and an exception might be thrown.

Yep. I mixed something up in my head.

Maybe UnauthorizedInterceptor is a better name?

I'm not sure about the naming and don't have any opinion on it. What about CheckAuthenticationInterceptor?

@provokateurin
Copy link
Member Author

I'm not sure about the naming and don't have any opinion on it. What about CheckAuthenticationInterceptor?

It still doesn't really convey what it is doing. I think something like UnauthorizedThrottlingInterceptor describes the functionality the best way, but it is still not intuitive. Maybe there simply is no good name for it.

@provokateurin provokateurin force-pushed the feat/neon_http_client/authentication-interceptor branch from 4bf824d to 114487b Compare September 9, 2024 06:20
@provokateurin provokateurin merged commit f9a57dd into main Sep 9, 2024
10 checks passed
@provokateurin provokateurin deleted the feat/neon_http_client/authentication-interceptor branch September 9, 2024 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't spam servers when unauthenticated
2 participants